﻿using StartTools.deleg;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace StartTools
{
    public partial class AddOrUpdate : Form
    {
        private AddRow add;
        public AddOrUpdate(AddRow add)
        {
            InitializeComponent();
            this.add = add;
        }
        public AddOrUpdate(AddRow add,string title,string path)
        {
            InitializeComponent();
            this.add = add;
            this.textBox_path.Text = path;
            this.textBox_title.Text= title;
            this.textBox_path.ReadOnly = true;
            this.button1.Text = "Update";
        }
        private void button2_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string title = textBox_title.Text;
            string path = textBox_path.Text;
            if (string.IsNullOrWhiteSpace(title))
            {
                MessageBox.Show("标题不能为空！");
                return;
            }
            if (string.IsNullOrWhiteSpace(path))
            {
                MessageBox.Show("路径不能为空！");
                return;
            }
            add(title,path);
            this.Close();
        }
    }
}
